package com.shaohai.live.ui;

import android.content.Context;
import android.content.Intent;

import com.qmuiteam.qmui.widget.QMUITopBarLayout;
import com.shaohai.live.R;

import butterknife.BindView;


public abstract class FSBarActivity extends FSActivity {
    @BindView(R.id.topBar) protected QMUITopBarLayout mTopBar;

    protected void initTopBar(String title) {
        initTopBar(title, false);
    }

    protected void initTopBar(String title, boolean hasBackButton) {
        mTopBar.setTitle(title);
        if (hasBackButton)
            mTopBar.addLeftBackImageButton().setOnClickListener(v -> finish());
    }

    protected void initTopBar(String title, Class<?> redirectActivity) {
        mTopBar.setTitle(title);
        mTopBar.addLeftBackImageButton().setOnClickListener(v -> {
            Intent intent = new Intent(context, redirectActivity);
            startActivity(intent);
            finish();
        });
    }
}
